package com.education.api.controller.student;

import com.education.business.service.education.TopicInfoService;
import com.education.common.utils.Result;
import com.education.model.dto.TopicDTO;
import com.education.model.request.PageParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/student/topic")
public class StuTopicInfoController {

    @Resource
    private TopicInfoService topicInfoService;

    /**
     * 学生端/机构端 - 创建主题
     *
     * @return
     */
    @PostMapping
    public Result createTopic(@RequestBody TopicDTO dto) {
        topicInfoService.createTopic(dto);
        return Result.success();
    }

    /**
     * 主题回复:学生老师均可回复
     *
     * @return
     */
    @PostMapping("/reply")
    public Result reply(@RequestBody TopicDTO dto) {
        topicInfoService.replyTopic(dto);
        return Result.success();
    }

    /**
     * 学生端 - 查看主题
     *
     * @param pageParam
     * @return
     */
    @GetMapping("/list")
    public Result list(PageParam pageParam, Integer courseId) {
        return Result.success(topicInfoService.selectContentList(pageParam, null, courseId));
    }
}
